class Solution:
    def reverseWords(self, s: str) -> str:
        S = s.split(' ')
        res = []
        for i in S[::-1]:
            if i != '':
                res.append(i)

        return ' '.join(res)


if __name__ == '__main__':
    s=Solution()
    ss="the sky    is blue"
    print(ss.split(' '))
    ans=s.reverseWords(ss)
    print(ans)